- name: d8.prometheus.target_down
  rules:
  - alert: TargetDown
    expr: up == 0 unless on (job) ALERTS{alertname=~".+TargetDown"}
    for: 10m
    labels:
      severity_level: "7"
    annotations:
      plk_protocol_version: "1"
      plk_labels_as_annotations: "instance,pod"
      description: '{{ $labels.job }} target is down.'
      summary: Target is down

  - alert: TargetDown
    expr: up == 0 unless on (job) ALERTS{alertname=~".+TargetDown"}
    for: 30m
    labels:
      severity_level: "6"
    annotations:
      plk_protocol_version: "1"
      plk_labels_as_annotations: "instance,pod"
      description: '{{ $labels.job }} target is down.'
      summary: Target is down

  - alert: TargetDown
    expr: up == 0 unless on (job) ALERTS{alertname=~".+TargetDown"}
    for: 60m
    labels:
      severity_level: "5"
    annotations:
      plk_protocol_version: "1"
      plk_labels_as_annotations: "instance,pod"
      description: '{{ $labels.job }} target is down.'
      summary: Target is down

  - alert: TargetSampleLimitExceeded
    expr: |
      scrape_samples_post_metric_relabeling / scrape_sample_limit > 1
      and scrape_sample_limit !=0
    for: __SCRAPE_INTERVAL_X_2__
    labels:
      severity_level: "6"
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      plk_labels_as_annotations: "instance,pod"
      description: |
        Target are down because of a sample limit exceeded.
      summary: Scrapes are exceeding sample limit

  - alert: TargetSampleLimitExceeded
    expr: |
      scrape_samples_post_metric_relabeling / scrape_sample_limit > 0.9
      and scrape_sample_limit !=0
    for: __SCRAPE_INTERVAL_X_2__
    labels:
      severity_level: "7"
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      plk_labels_as_annotations: "instance,pod"
      description: |
        The target is close to exceeding the sampling limit. less than 10% left to the limit
      summary: The sampling limit is close.
